<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">
    
    <title>Form Layouts</title>
    
    <?php $this->load->view('library/header');?>
</head>

<body class="sticky-header">

<section>
    <?php $this->load->view('library/left');?>
    
    <!-- main content start-->
    <div class="main-content" >
        
        <?php $this->load->view('library/top');?>
        
        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                添加尺码
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Forms</a>
                </li>
                <li class="active"> Forms Layouts </li>
            </ul>
        </div>
        <!-- page heading end-->
        
        <!--body wrapper start-->
        <section class="wrapper">
            <!-- page start-->
            
            <div class="row">
                <div class="col-lg-12">
                    <form id="commentForm" class="form-horizontal adminex-form" method="post">
                    <section class="panel">
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">尺码英文名</label>
                                <div class="col-sm-10">
                                    <input type="text" value="<?php echo $size['size_value'];?>" name="size_value" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">尺码中文名</label>
                                <div class="col-sm-10">
                                    <input type="text" value="<?php echo $size['size_code'];?>" name="size_code" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">类型</label>
                                <div class="col-sm-10">
                                    <select name="size_type" class="form-control">
                                        <option <?php echo $size['size_type'] == 2 ? 'selected' : '';?> value="2">衣服</option>
                                        <option <?php echo $size['size_type'] == 1 ? 'selected' : '';?> value="1">鞋子</option>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">对应尺寸编码</label>
                                <div class="col-sm-10">
                                    <select name="new_size_code" class="form-control">
                                        <?php foreach($size_code as $key => $value): ?>
                                        <option <?php echo $size['new_size_code'] == $key ? 'selected' : '';?>  value="<?php echo $key;?>"><?php echo $value;?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </div>
                            </div>


                            <div class="form-group ">
                                  <label for="curl" class="control-label col-lg-2">是否显示</label>
                                  <div class="col-lg-2">
                                      <select name="is_delete" class="form-control">
                                          <option <?php echo $size['is_delete'] == 0 ? 'selected="selected"' : '';?> value="0">是</option>
                                          <option <?php echo $size['is_delete'] == 1 ? 'selected="selected"' : '';?> value="1">否</option>
                                      </select>
                                  </div>
                              </div>


                            <div class="form-group">
                                <label class="col-lg-2 col-sm-2 control-label"></label>
                                <div class="col-lg-10">
                                    <button type="submit" class="btn btn-primary">Submit</button>
                                </div>
                            </div>
                        </div>
                    </section>
                    </form>
                </div>
            </div>
            <!-- page end-->
        </section>
        <!--body wrapper end-->
        
        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by
        </footer>
        <!--footer section end-->
    
    
    </div>
    <!-- main content end-->
</section>

<?php $this->load->view('library/footer');?>

<script>
    $(function () {
        
        $('#commentForm').submit(function () {

            t = setTimeout(function() {
                $('.btn-primary').attr('disabled','disabled');
            }, 200);


            var data = new FormData(this);

            $.ajax({
                type: 'POST',
                url: '<?php echo base_url('siteweb/size_set'. ($size ? "/id/{$size['size_id']}" : ''));?>',
                data: data,
                success: function (data) {
                    clearTimeout(t);
                    if (data.status != 'success') {
                        swal({
                            title: data.info,
                            text: '2秒后关闭',
                            type: data.status,
                            allowOutsideClick: false,
                            timer: 1500,
                            showConfirmButton: false
                        });
                        $('.btn-primary').attr("disabled",false);
                    } else {
                        swal({
                            title: data.info,
                            text: '2秒后关闭',
                            type: data.status,
                            allowOutsideClick: false,
                            timer: data.stop ? data.stop : 1500,
                            showConfirmButton: false
                        }).then(function(isConfirm) {
                            window.onbeforeunload = '';
                            window.location.href = '<?php echo base_url('siteweb/size_list');?>';
                        });
                        $('.btn-primary').removeClass('btn-submit-disabled').html(data.info);
                    }

                },
                dataType:'json',
                cache: false,
                contentType: false,
                processData: false
            });

            return false;
        });
        
    });
</script>

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>

</body>
</html>